using System.Collections.Generic;
using System.Text;
using System;
using NHibernate;
using NHibernate.Cfg;
using JVLMRP;
namespace JVLMRP 
{
    public class MRPExportTypesService
    {
        ISession session;

        public MRPExportTypesService(ISession session)
        {
            this.session = session;
        }
        public MRPExportTypesService()
        {
            this.session = SessionFactory.GetNewSession();
        }
        public void InsertMrpexporttypes(MRPExportTypes mrpexporttypesX)
        {
            ITransaction tx = session.BeginTransaction();
            session.Save(mrpexporttypesX);
            tx.Commit();
        }

        public void UpdateMrpexporttypes(MRPExportTypes mrpexporttypesX)
        {
            ITransaction tx = session.BeginTransaction();
            session.Update(mrpexporttypesX);
            tx.Commit();
        }

        public void DeleteMrpexporttypes(MRPExportTypes mrpexporttypesX)
        {
            ITransaction tx = session.BeginTransaction();
            session.Delete(mrpexporttypesX);
            tx.Commit();
        }

        public IList<MRPExportTypes> GetAllMrpexporttypes(Boolean evict)
        {
            IQuery query = session.CreateQuery("select from MRPExportTypes");
            IList<MRPExportTypes> list = query.List<MRPExportTypes>();
            if (evict)
            {
                foreach (MRPExportTypes s in list)
                {
                    session.Evict(s);
                }
            }
            return list;
        }

        public MRPExportTypes GetAllMrpexporttypesByID(String id, Boolean evict)
        {
            IQuery query = session.CreateQuery("select c from MRPExportTypes as c where c.Exporttypecode= :x");
            query.SetString("x", id);
            MRPExportTypes s = (MRPExportTypes)query.UniqueResult();
            if (evict)
            {
                session.Evict(s);
            }
            return s;
        }

        public IList<MRPExportTypes> GetMrpexporttypesByQuery(IQuery query, Boolean evict)
        {
            IList<MRPExportTypes> list = query.List<MRPExportTypes>();
            if (evict)
            {
                foreach (MRPExportTypes s in list)
                {
                    session.Evict(s);
                }
            }
            return list;
        }
    }
}
